package com.why.cachecloud.web.controller;

import com.why.cachecloud.entity.CommandLog;
import com.why.cachecloud.web.enums.SuccessEnum;
import com.why.cachecloud.web.service.CommandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 命令执行管理界面
 */
@Controller
@RequestMapping("manage/command")
public class CommandController {

    @Autowired
    private CommandService commandService;

    /**
     * 命令列表
     */
    @RequestMapping(value = "/list")
    public ModelAndView doUserList(Model model, CommandLog log) {

        List<CommandLog> commandLogs = commandService.getList(log);
        model.addAttribute("commandLogs", commandLogs);
        model.addAttribute("log", log);
        model.addAttribute("commandActive", SuccessEnum.SUCCESS.value());
        return new ModelAndView("manage/command/list");
    }

}
